package com.ruoyi.busfront.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.busfront.domain.BusfrontIntro;
import com.ruoyi.busfront.service.IBusfrontIntroService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 区域营商环境介绍（前台）Controller
 *
 * @author MagicCube
 * @date 2023-05-04
 */
@RestController
@RequestMapping("/busfrontIntro")
public class BusfrontIntroController extends BaseController
{
    @Autowired
    private IBusfrontIntroService busfrontIntroService;

    /**
     * 综合推荐
     * 查询区域营商环境介绍（前台）列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BusfrontIntro busfrontIntro)
    {
        startPage();
        List<BusfrontIntro> list = busfrontIntroService.selectBusfrontIntroList(busfrontIntro);
        return getDataTable(list);
    }
    @GetMapping("/nearbyList")
    public TableDataInfo nearbyList(BusfrontIntro busfrontIntro)
    {
        startPage();
        List<BusfrontIntro> list = busfrontIntroService.selectBusfrontIntroListz(busfrontIntro);
        return getDataTable(list);
    }

    /**
     * 人气最旺
     * 查询区域营商环境介绍（前台）列表
     */
    @GetMapping("/popularList")
    public TableDataInfo popularList(BusfrontIntro busfrontIntro)
    {
        startPage();
        List<BusfrontIntro> list = busfrontIntroService.selectBusfrontIntroPopularList(busfrontIntro);
        return getDataTable(list);
    }


    /**
     * 最新上架
     * 查询区域营商环境介绍（前台）列表
     */
    @GetMapping("/newlyAddedList")
    public TableDataInfo newlyAddedList(BusfrontIntro busfrontIntro)
    {
        startPage();
        List<BusfrontIntro> list = busfrontIntroService.selectBusfrontIntroNewlyAddedList(busfrontIntro);
        return getDataTable(list);
    }
    /**
     * 导出区域营商环境介绍（前台）列表
     */
    @Log(title = "区域营商环境介绍（前台）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusfrontIntro busfrontIntro)
    {
        List<BusfrontIntro> list = busfrontIntroService.selectBusfrontIntroList(busfrontIntro);
        ExcelUtil<BusfrontIntro> util = new ExcelUtil<BusfrontIntro>(BusfrontIntro.class);
        util.exportExcel(response, list, "区域营商环境介绍（前台）数据");
    }

    /**
     * 获取区域营商环境介绍（前台）详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(busfrontIntroService.selectBusfrontIntroById(id));
    }

    /**
     * 新增区域营商环境介绍（前台）
     */
    @Log(title = "区域营商环境介绍（前台）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusfrontIntro busfrontIntro)
    {
        return toAjax(busfrontIntroService.insertBusfrontIntro(busfrontIntro));
    }

    /**
     * 修改区域营商环境介绍（前台）
     */
    @Log(title = "区域营商环境介绍（前台）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusfrontIntro busfrontIntro)
    {
        return toAjax(busfrontIntroService.updateBusfrontIntro(busfrontIntro));
    }

    /**
     * 删除区域营商环境介绍（前台）
     */
    @Log(title = "区域营商环境介绍（前台）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(busfrontIntroService.deleteBusfrontIntroByIds(ids));
    }
}
